//
//  NearAcInfoCell.m
//  Shengzhuli
//
//  Created by FXGuo on 2017/8/8.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "NearAcInfoCell.h"
#import <UIImageView+WebCache.h>
#import "SZLAccountHelper.h"
#import "MBProgressHUD+MJ.h"
#import "YYText.h"
#import "NSAttributedString+YYText.h"

@interface NearAcInfoCell ()

@property (weak, nonatomic) IBOutlet UIImageView *bgImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLab;
@property (weak, nonatomic) IBOutlet UIImageView *avatarImageView;
@property (weak, nonatomic) IBOutlet UILabel *clubNameLab;
@property (weak, nonatomic) IBOutlet UILabel *timeLab;
@property (weak, nonatomic) IBOutlet UILabel *addressLab;
@property (weak, nonatomic) IBOutlet UIView *infoView;
@property (weak, nonatomic) IBOutlet UIImageView *avatorTwoView;
@property (weak, nonatomic) IBOutlet YYLabel *clubNameImageLab;

@property (weak, nonatomic) IBOutlet UILabel *clubDesLab;

@property (weak, nonatomic) IBOutlet UIButton *focusBtn;



@end

@implementation NearAcInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.infoView.layer.borderWidth = 1.0;
    self.infoView.layer.borderColor = RGBColor(234, 111, 90).CGColor;
    self.focusBtn.layer.borderWidth = 1;
    self.focusBtn.layer.borderColor = RGBColor(234, 111, 90).CGColor;
}
- (IBAction)clubClick:(UIButton *)btn
{
    if (self.clubClick) {
        self.clubClick();
    }
}


- (IBAction)focusClick:(UIButton *)btn
{
    if ([[SZLAccountHelper shareInstance].mobilePhone isEqualToString:self.model.mobilePhone]) {
        [MBProgressHUD showError:@"不能关注自己的俱乐部"];
        return;
    }
    if (self.focusClick) {
        self.focusClick(btn,self.model.keepStatus);
    }
}
- (void)setModel:(ActivityDetailModel *)model
{
    _model = model;
    if (!model) return;
    [self.bgImageView sd_setImageWithURL:[NSURL URLWithString:model.backgroundImg] placeholderImage:GetImage(@"default_goods_image")];
    self.titleLab.text = model.title;
    [self.avatarImageView sd_setImageWithURL:[NSURL URLWithString:model.clubLogo] placeholderImage:GetImage(@"person_avatar")];
    self.clubNameLab.text = model.clubName;
    
    self.timeLab.text = model.holdDate;
    self.addressLab.text = model.address;
    [self.avatorTwoView sd_setImageWithURL:[NSURL URLWithString:model.clubLogo] placeholderImage:GetImage(@"default_goods_image")];
    
    
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:model.clubName];
    attri.yy_font = [UIFont systemFontOfSize:15];
    attri.yy_color = [UIColor blackColor];
    attri.yy_alignment = NSTextAlignmentJustified;
    //增加图片之间的间距
    [attri appendAttributedString:[[NSAttributedString alloc]initWithString:@"  "]];
    
    UIImage *image = [UIImage imageNamed:@"认证担保"];
    image = [UIImage imageWithCGImage:image.CGImage scale:2 orientation:UIImageOrientationUp];
    NSMutableAttributedString *attachText = [NSMutableAttributedString yy_attachmentStringWithContent:image contentMode:UIViewContentModeScaleToFill attachmentSize:CGSizeMake(16, 16) alignToFont:Font(15) alignment:YYTextVerticalAlignmentCenter];
    [attri appendAttributedString:attachText];
    //增加图片之间的间距
    [attri appendAttributedString:[[NSAttributedString alloc]initWithString:@"  "]];
    
    UIImage *imageTwo = [UIImage imageNamed:@"主办方"];
    imageTwo = [UIImage imageWithCGImage:imageTwo.CGImage scale:2 orientation:UIImageOrientationUp];
    NSMutableAttributedString *attachTextTwo = [NSMutableAttributedString yy_attachmentStringWithContent:imageTwo contentMode:UIViewContentModeScaleToFill attachmentSize:CGSizeMake(32, 16) alignToFont:Font(15) alignment:YYTextVerticalAlignmentCenter];
    [attri appendAttributedString:attachTextTwo];
    
    self.clubNameImageLab.attributedText = attri;
    
    self.clubDesLab.text = model.clubContent;
    if (model.keepStatus == 0) {
        [self.focusBtn setTitle:@"+关注" forState:UIControlStateNormal];
    }else {
        [self.focusBtn setTitle:@"已关注" forState:UIControlStateNormal];
    }
}



@end
